
    /**
 * Implementation of the data model's facade.
 */
package us.gaaoc.framework.dao;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import us.gaaoc.framework.businessmodel.Filing;
import us.gaaoc.framework.businessmodel.FilingPerson;
import us.gaaoc.framework.model.Address;
import us.gaaoc.framework.model.AddressCategory;
import us.gaaoc.framework.model.AddressType;
import us.gaaoc.framework.model.Attorney;
import us.gaaoc.framework.model.CaseRecord;
import us.gaaoc.framework.model.CaseRecordAction;
import us.gaaoc.framework.model.CaseRecordEventType;
import us.gaaoc.framework.model.CaseRecordIdExternalCaseRecordNumber;
import us.gaaoc.framework.model.CaseRecordHistory;
import us.gaaoc.framework.model.CaseRecordStatus;
import us.gaaoc.framework.model.CaseRecordType;
import us.gaaoc.framework.model.Counter;
import us.gaaoc.framework.model.CounterPerSigner;
import us.gaaoc.framework.model.Court;
import us.gaaoc.framework.model.CourtEventType;
import us.gaaoc.framework.model.CourtEvents;
import us.gaaoc.framework.model.CourtHearingNegotiations;
import us.gaaoc.framework.model.CourtSeal;
import us.gaaoc.framework.model.DocPageRange;
import us.gaaoc.framework.model.DocumentBinaries;
import us.gaaoc.framework.model.DocumentInstance;
import us.gaaoc.framework.model.DocumentLocalCode;
import us.gaaoc.framework.model.DocumentPackage;
import us.gaaoc.framework.model.DocumentSigConfig;
import us.gaaoc.framework.model.DocumentStatus;
import us.gaaoc.framework.model.DocumentType;
import us.gaaoc.framework.model.Documents;
import us.gaaoc.framework.model.FilingAudit;
import us.gaaoc.framework.model.FilingSearch;
import us.gaaoc.framework.model.LdapDirectoryOrganization;
import us.gaaoc.framework.model.LdapDirectoryPerson;
import us.gaaoc.framework.model.LegalPreparer;
import us.gaaoc.framework.model.LocalCaseCategory;
import us.gaaoc.framework.model.LocalCaseDivision;
import us.gaaoc.framework.model.LocalCaseFilingType;
import us.gaaoc.framework.model.LocalCaseType;
import us.gaaoc.framework.model.LocalCourtEventType;
import us.gaaoc.framework.model.LocalParticipantRelationship;
import us.gaaoc.framework.model.OrgParticipants;
import us.gaaoc.framework.model.OrganizationAddress;
import us.gaaoc.framework.model.Organizations;
import us.gaaoc.framework.model.ParticipantRelationship;
import us.gaaoc.framework.model.Person;
import us.gaaoc.framework.model.PersonAddress;
import us.gaaoc.framework.model.PersonHashedSSN;
import us.gaaoc.framework.model.PersonOrganizations;
import us.gaaoc.framework.model.PersonParticipants;
import us.gaaoc.framework.model.Profile;
import us.gaaoc.framework.model.Roles;
import us.gaaoc.framework.model.SignatureImage;
import us.gaaoc.framework.model.Signatures;
import us.gaaoc.framework.model.VisualMark;
import us.gaaoc.framework.model.VisualMarkCategory;
import us.gaaoc.framework.model.util.CaseRecordsCountPerDay;
import us.gaaoc.framework.model.util.CaseRecordsCountPerMonth;
import us.gaaoc.framework.model.util.DismissedCases;
import us.gaaoc.framework.model.util.DismissedCasesPerMonth;
import us.gaaoc.framework.model.util.DocumentsCountByType;
import us.gaaoc.framework.model.util.DocumentsCountPerMonth;
import us.gaaoc.framework.util.DateUtil;

/**
 * @author robinsom
 * 
 */
@Configurable(dependencyCheck=true,autowire=Autowire.BY_TYPE)
@Scope("prototype")
@Component
public class ModelFacadeHibernate implements ModelFacade {

	// log4j Logger instance
	private static final Logger LOG = Logger.getLogger(ModelFacadeHibernate.class);
	
	private static ModelFacadeHibernate instance;
	
	public ModelFacadeHibernate(){}
	
	public synchronized static ModelFacadeHibernate getInstance() {
		if(instance == null){
			instance = new ModelFacadeHibernate();
		}
		return instance;
	}
    
	public Person login(String username, String password) {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO.login(username, password);
	}

	public Person getPersonByUserName(String username){
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO.getPersonByUserName(username);		
	}
	
	public Profile getPersonProfileByEmail(String email){
		ProfileDAO profileDAO = DAOFactory.DEFAULT.getProfileDAO();
		return profileDAO.getPersonProfileByEmail(email);	
	}
	
	public Person makePersistent(Person person) {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO.makePersistent(person);
	}
	
	public List<Person> getAllPeople() {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		List<Person> people = personDAO.findAll();
		return people;
	}
	
	/* Commented by: Ramu (Eppakayr)
	 * 
	 * public List<Person> getNonDeletedPersonWithNonNullUserId(){
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		List<Person> person = personDAO.getNonDeletedPersonWithNonNullUserId();
		return person;
	}*/
	
	public List<Person> getNonDeletedPersonWithNonNullUserId(String courtUuid){
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		List<Person> person = personDAO.getNonDeletedPersonWithNonNullUserId(courtUuid);
		return person;
	}
	
	public List<Person> getNonDeletedPerson(){
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		List<Person> person = personDAO.getNonDeletedPerson();
		return person;
	}
	
	public void updatePersonForDeletedFlag(String personUuid, byte isDeleted){
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		personDAO.updatePersonForDeletedFlag(personUuid,isDeleted);
		
	}
	

	public List<CaseRecord> findAllCaseRecordByStatus(int statusCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		List<CaseRecord> caseRecord = caseRecordDAO.findAllCaseRecordByStatus(statusCode);
		return caseRecord;
	}
	public List<CaseRecord> findAllCaseRecordByCaseType(int caseTypeCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		List<CaseRecord> caseRecord = caseRecordDAO.findAllCaseRecordByCaseType(caseTypeCode);
		return caseRecord;
	}
 	
	public List<Filing> findCaseFilingsByType(int typeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsByType(typeCode);
	}
	
	
	
	@SuppressWarnings("unused")
	private List<Filing> getFilingsWithEventFilerandDefendant(List<CaseRecord> caseRecords){
		List<Filing> filings = new ArrayList<Filing>();
		CaseRecordHistoryDAO crhDAO = DAOFactory.DEFAULT.getCaseRecordHistoryDAO();
		PersonParticipantsDAO ppDAO = DAOFactory.DEFAULT.getPersonParticipantsDAO();
		if (caseRecords !=null && !caseRecords.isEmpty()){
			for (CaseRecord cr : caseRecords){
				String uuid = cr.getUuid();
				String caseTrackingID = cr.getCaseTrackingId();
				String status = cr.getStatus().getDescription();
				Date instantiationDate = cr.getInstantiationDateTime();
				CaseRecordType crt = cr.getCaseType();
				String caseTypeDescription = crt.getDescription();
				
				Filing f = new Filing(uuid, caseTrackingID, status, instantiationDate);
				
				CaseRecordHistory crh = crhDAO.findLatestEventByCaseRecord(cr);
				Date eventDate = crh.getEventDateTime();
				String eventType = crh.getEventType().getDescription();
				f.setEventDateTime(eventDate);
				f.setEventType(eventType);
				f.setCaseType(caseTypeDescription);
				
				List<FilingPerson> persons = ppDAO.findFilerandDefendant(cr);
				if (persons != null && !persons.isEmpty()){
					for (FilingPerson p : persons){
						if (p.getRelationshipCode()==6){
							f.setFilerName(p.getPerson().getFirstName()+ " " + p.getPerson().getLastName());
						}else {
							f.setDefendantName(p.getPerson().getFirstName() + " " + p.getPerson().getLastName());
						}
					}
				}
				filings.add(f);				
			}
		}		
		return filings;
	}
	
	
	public List<Filing> findCaseFilingsByTypeAndStatus(int typeCode, int statusCode, String courtUuid){		
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);		
		return caseRecordDAO.findCaseFilingsByTypeAndStatus(typeCode, statusCode);
		
	}   
	// Added for Paging of Imported Filings Queries
	public List<Filing> findCaseFilingsByTypeAndStatusPaged(int typeCode,
			int statusCode, int pageIndex, int limit, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsByTypeAndStatusPaged(typeCode, 
				statusCode, pageIndex, limit);
	}
	public int findNumberOfCaseFilingsByTypeAndStatus(int typeCode,
			int statusCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfCaseFilingsByTypeAndStatus(typeCode, 
				statusCode);
	}
		
	public List<Filing> findCaseFilingsByStatus(int statusCode, String courtUuid){ 
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);	
		return caseRecordDAO.findCaseFilingsByStatus(statusCode);
	}
	
	public  List<Filing> findClearedCaseFilingsByType(int typeCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findClearedCaseFilingsByType(typeCode);
	}
	
	public List<Filing> findErrorFilings() {
		CaseRecordHistoryDAO caseRecordHistoryDAO = DAOFactory.DEFAULT.getCaseRecordHistoryDAO();
		PersonParticipantsDAO ppDAO = DAOFactory.DEFAULT.getPersonParticipantsDAO();
		List<Filing> filings = caseRecordHistoryDAO.findCaseFilingswithErrorEvent();
		if (!filings.isEmpty() && filings!=null){
			for (Filing f : filings){
				String uuid = f.getUuid();
				List<FilingPerson> persons = ppDAO.findFilerandDefendantByCaseRecordUuid(uuid);
				if (persons != null && !persons.isEmpty()){
					for (FilingPerson p : persons){
						if (p.getRelationshipCode()==6){
							f.setFilerName(p.getPerson().getFirstName()+ " " + p.getPerson().getLastName());
						}else {
							f.setDefendantName(p.getPerson().getFirstName() + " " + p.getPerson().getLastName());
						}
					}
				}
			}
		}		
		return filings;
	}
	

	public List<Filing> findClearedCaseFilings(String courtUuid){
		CaseRecordDAO caseRecordDAO =DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findClearedCaseFilings();
	}
/*	
	public List<CaseRecord> findAllCaseRecordByInstantiationDateTime(){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO();
		List<CaseRecord> caseRecord = caseRecordDAO.findAllCaseRecordByInstantiationDateTime();
		return caseRecord;
	}
*/	
/*	public List<CaseRecord> findNewCaseRecord(){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO();
		List<CaseRecord> caseRecord = caseRecordDAO.findNewCaseRecord();
		return caseRecord;
	}  */

	public List<Organizations> findAllOrganizations() {
		OrganizationsDAO organizationsDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		List<Organizations> organizations = organizationsDAO.findAll();
		return organizations;
	}
	
	public List<Roles> findAllRoles() {
		RolesDAO rolesDAO = DAOFactory.DEFAULT.getRolesDAO();
		List<Roles> roles = rolesDAO.findAll();
		return roles;
	}

	public Organizations makePersistent(Organizations organization) {
		OrganizationsDAO organizationsDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		return organizationsDAO.makePersistent(organization);
	}
	
	public Roles makePersistent(Roles roles) {
		RolesDAO rolesDAO = DAOFactory.DEFAULT.getRolesDAO();
		return rolesDAO.makePersistent(roles);
	}

	
	public Person findPersonById(String uuid) {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		//return personDAO.findById(uuid, false);
		return personDAO.findById(uuid);
	}

	/*
	public Object findOrganizationById(String uuid) {
		OrganizationsDAO organizationsDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		return organizationsDAO.findById(uuid, false);
	}
	*/
	public Organizations findOrganizationById(String uuid) {
		OrganizationsDAO organizationsDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		//return organizationsDAO.findById(uuid, false);
		return organizationsDAO.findById(uuid);
	}

	public Object findRoleById(String uuid) {
		RolesDAO rolesDAO = DAOFactory.DEFAULT.getRolesDAO();
		//return rolesDAO.findById(uuid, false);
		return rolesDAO.findById(uuid);
	}

	public CaseRecord findCaseRecordById(String uuid, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		//return caseRecordDAO.findById(uuid, false);
		return caseRecordDAO.findById(uuid);
	}
	public List<CaseRecord> findAllCaseRecordByTransmissionError(String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAllCaseRecordByTransmissionError();
	}	
	public void updateCaseRecordForClearCase(String filingUuid, boolean clearInt, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		 caseRecordDAO.updateCaseRecordForClearCase(filingUuid,clearInt);
	}
	public Object findCaseEventById(String uuid){
		CourtEventsDAO  courtEventsDAO = DAOFactory.DEFAULT.getCourtEventsDAO();
		//return courtEventsDAO.findById(uuid,false);
		return courtEventsDAO.findById(uuid);
	}
	
	public  void updateCourtHearingNegotiationStausToRejected(CourtHearingNegotiations chn){
		CourtHearingNegotiationsDAO courtNegotiationsDAO = DAOFactory.DEFAULT.getCourtHearingNegotiationsDAO();
		courtNegotiationsDAO.updateCourtHearingNegotiationStausToRejected(chn);
	}
	
	public  void updateCourtHearingNegotiationStausToAccepted(CourtHearingNegotiations chn){
		CourtHearingNegotiationsDAO courtNegotiationsDAO = DAOFactory.DEFAULT.getCourtHearingNegotiationsDAO();
		courtNegotiationsDAO.updateCourtHearingNegotiationStausToAccepted(chn);
	}
	
	public CourtHearingNegotiations findCourtHearingNegotiationsByCaseRecordUuid(String caseRecordUuid){
		CourtHearingNegotiationsDAO courtNegotiationsDAO = DAOFactory.DEFAULT.getCourtHearingNegotiationsDAO();
		return courtNegotiationsDAO.findCourtHearingNegotiationsByCaseRecordUuid(caseRecordUuid);
	}
	
	public List<CaseRecord> findAllClearedCaseRecords(boolean flag, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		List<CaseRecord> caseRecord = caseRecordDAO.findAllClearedCaseRecords(flag);
		return caseRecord;
	}
	
	public  void updateCourtDate(String caseRecordUuid, Date courtDate, String personUuid){
		CourtEventsDAO  courtEventsDAO = DAOFactory.DEFAULT.getCourtEventsDAO();
		courtEventsDAO.updateCourtDate(caseRecordUuid,courtDate, personUuid);
	}
	public Date findCourtDate(String caseRecordUuid){
		CourtEventsDAO  courtEventsDAO = DAOFactory.DEFAULT.getCourtEventsDAO();
		return courtEventsDAO.findCourtDate(caseRecordUuid);
	}
    
	// just to set the deleted flag to true
	public void removeCaseRecord(String uuid, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		caseRecordDAO.updateCaseRecordForDeletedFlag(uuid, true);
			
	}
/*
	public CaseRecord findCaseRecordByDocketID(String docketID,String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO();
		CaseRecord c = caseRecordDAO.findCaseRecordByDocketID(docketID,courtUuid);
		return c;
	}
*/
	
	@Deprecated
	public CaseRecord findCaseRecordByDocketID(String docketID, String courtUuid) {
		throw new UnsupportedOperationException("findCaseRecordByDocketID is unsupported!");
	}
	
	public Documents findDocumentsByInstanceAndCaseUuid(String docTypeCode, String caseUuid) {
		 DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 Documents doc = documentsDAO.findDocumentsByInstanceAndCaseUuid(docTypeCode, caseUuid);
		 return doc;
	}

	public List<Documents> findDocumentsByCaseUuid(String caseUuid) {
		 DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return documentsDAO.findDocumentsByCaseUuid(caseUuid);
	}

	public void updateCaseRecordStatus(String uuid, CaseRecordStatus status, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		//CaseRecord c = caseRecordDAO.findById(uuid, true);
		CaseRecord c = caseRecordDAO.findById(uuid);
		c.setStatus(status);
		caseRecordDAO.makePersistent(c);		
	}

	public void updateImportedCaseRecord(String uuid, String docketID, int statusCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		CaseRecordStatusDAO crsDAO = DAOFactory.DEFAULT.getCaseRecordStatusDAO();		
		//caseRecordDAO.updateImportedCaseRecord(uuid, docketID, crsDAO.findById(statusCode, false));		
		caseRecordDAO.updateImportedCaseRecord(uuid, docketID, crsDAO.findById(statusCode));	
	}
	
	public void updateCaseRecordCourtTrackingID(String uuid, String docketID, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		caseRecordDAO.updateCaseRecordCourtTrackingID(uuid, docketID);
	}

	public void updateRejectedCaseRecord(String uuid, String reason, int statusCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		CaseRecordStatusDAO crsDAO = DAOFactory.DEFAULT.getCaseRecordStatusDAO();
		//caseRecordDAO.updateRejectedCaseRecord(uuid, reason, crsDAO.findById(statusCode, false));	
		caseRecordDAO.updateRejectedCaseRecord(uuid, reason, crsDAO.findById(statusCode));	
		
	}

	public void addCaseRecordHistory(String caseRecordUuid, int eventTypeCode, Person person, String courtUuid,String comments) {
		CaseRecordDAO crDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		//CaseRecord caseRecord = crDAO.findById(caseRecordUuid, false);
		CaseRecord caseRecord = crDAO.findById(caseRecordUuid);
		
		CaseRecordEventTypeDAO cretDAO = DAOFactory.DEFAULT.getCaseRecordEventTypeDAO();
		//CaseRecordEventType event = cretDAO.findById(eventTypeCode, false);
		CaseRecordEventType event = cretDAO.findById(eventTypeCode);
		
		CaseRecordHistoryDAO crhDAO = DAOFactory.DEFAULT.getCaseRecordHistoryDAO();
		
		CaseRecordHistory crh = new CaseRecordHistory();
		crh.setComments(comments);
		crh.setCaseRecord(caseRecord);
		crh.setEventType(event);
		Date eventDate = DateUtil.getCurrentDate();
		String dateString = eventDate.toString();
		LOG.debug("Date and Time of Current Case Record History Event: "
				+ dateString);
		crh.setEventDateTime(eventDate);
		crh.setPerson(person);
		crhDAO.makePersistent(crh);
		
	}
	
	public void addCaseRecordHistory(String caseRecordUuid, String courtUuid,
			int eventTypeCode, Person person,String comments) {
		CaseRecordDAO crDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		//CaseRecord caseRecord = crDAO.findById(caseRecordUuid, false);
		CaseRecord caseRecord = crDAO.findById(caseRecordUuid);
		
		CaseRecordEventTypeDAO cretDAO = DAOFactory.DEFAULT.getCaseRecordEventTypeDAO();
		//CaseRecordEventType event = cretDAO.findById(eventTypeCode, false);
		CaseRecordEventType event = cretDAO.findById(eventTypeCode);
		
		CaseRecordHistoryDAO crhDAO = DAOFactory.DEFAULT.getCaseRecordHistoryDAO();
		
		CaseRecordHistory crh = new CaseRecordHistory();
		crh.setCaseRecord(caseRecord);
		crh.setEventType(event);
		crh.setComments(comments);
		Date eventDate = DateUtil.getCurrentDate();
		if (eventTypeCode == 1) {
			// Use Banker's Hours for Bibb County Received by Court Date
			//TODO: getConditionalCurrentDate should return the date based on the
			// given court anyway.
			if (courtUuid.equals("courtUuid")) {
				eventDate = DateUtil.getConditionalCurrentDate(courtUuid);
			} else {
			   eventDate = DateUtil.getCurrentDate();
			}
		}
		String dateString = eventDate.toString();
		LOG.debug("Date and Time of Current Case Record History Event: "
				+ dateString);
		crh.setEventDateTime(eventDate);
		crh.setPerson(person);
		crhDAO.makePersistent(crh);
		
	}

	public List<CaseRecordHistory> findHistoryByCaseRecordID(String caseUuid, String courtUuid) {
		CaseRecordDAO crDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		CaseRecordHistoryDAO crhDAO = DAOFactory.DEFAULT.getCaseRecordHistoryDAO();
		//CaseRecord cr = crDAO.findById(caseUuid, false);
		CaseRecord cr = crDAO.findById(caseUuid);
		return crhDAO.findHistoryByCaseRecord(cr); 
	}

	
	
	/******************** Angela added for GAJE_DataModel ******************************************/

	public Court findCourt(String courtUuid) {
	//public Organizations findOrganization(String courtUuid) {
		CourtDAO courtDAO = DAOFactory.DEFAULT.getCourtDAO();
		return courtDAO.findById(courtUuid);	
		//OrganizationsDAO organizationDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		//return organizationDAO.findById(courtUuid);
	}

	public CaseRecord insertCaseRecord(CaseRecord cr, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		cr = caseRecordDAO.makePersistent(cr);
		if(cr.getUuid() != null && !cr.getUuid().isEmpty()){
			cr.setFilingId(cr.getUuid());
			caseRecordDAO.updateCaseRecord(cr);
		}		
		return cr;
	}

	public Person findPersonByName(String first, String middle, String last) {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO.findByPersonName(first, middle, last); 
	}

	public Person insertPerson(Person p) {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO.makePersistent(p);		
	}

	public ParticipantRelationship findParticipantRelationship(int id) {
		ParticipantRelationshipDAO participantRelationshipDAO = DAOFactory.DEFAULT.getParticipantRelationshipDAO();
		//return participantRelationshipDAO.findById(Integer.valueOf(id), false);
		return participantRelationshipDAO.findById(Integer.valueOf(id));
		 
	}

	public PersonParticipants insertPersonParticipants(PersonParticipants pp) {
		PersonParticipantsDAO ppDAO = DAOFactory.DEFAULT.getPersonParticipantsDAO();		
		return ppDAO.makePersistent(pp);
	}

	public AddressType findAddressType(int id) {
		new Exception("findAddressType - currently broken").printStackTrace();
		AddressTypeDAO atDAO = DAOFactory.DEFAULT.getAddressTypeDAO();
		//return atDAO.findById(Integer.valueOf(id), false);		
		return atDAO.findById(Integer.valueOf(id));
	}

	public PersonAddress insertPersonAddress(PersonAddress address) {
		PersonAddressDAO paDAO = DAOFactory.DEFAULT.getPersonAddressDAO();
		return paDAO.makePersistent(address);
		
 	}

	public PersonAddress findPersonAddress(Person p, String addressUuid) {
		PersonAddressDAO paDAO = DAOFactory.DEFAULT.getPersonAddressDAO();
		return paDAO.findPersonAddress(p, addressUuid); 
	}

	public Attorney findAttorneyByBarID(String barID) {
		AttorneyDAO aDAO = DAOFactory.DEFAULT.getAttorneyDAO();
		return aDAO.findAttorneyByBarID(barID); 
	}

	public void insertAttorney(Attorney att) {
		AttorneyDAO aDAO = DAOFactory.DEFAULT.getAttorneyDAO();
		aDAO.makePersistent(att);
		
	}

	public Organizations findOrganizationByName(String orgName) {
		OrganizationsDAO orgDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		return orgDAO.findOrgByName(orgName);
	}

	public void insertOrganizations(Organizations org) {
		OrganizationsDAO orgDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		orgDAO.makePersistent(org);		
	}

	public void insertOrgParticipants(OrgParticipants orgParticipants) {
		OrgParticipantsDAO orgPatDAO = DAOFactory.DEFAULT.getOrgParticipantsDAO();
		orgPatDAO.makePersistent(orgParticipants);
		
	}

	public void insertOrganizationAddress(OrganizationAddress oa) {
		OrganizationAddressDAO oaDAO = DAOFactory.DEFAULT.getOrganizationAddressDAO();
		oaDAO.makePersistent(oa);
		
	}

	public OrganizationAddress findOrgAddress(Organizations org, String streetAddressText) {
		OrganizationAddressDAO oaDAO = DAOFactory.DEFAULT.getOrganizationAddressDAO();
		return oaDAO.findOrgAddress(org, streetAddressText);
		 
	}

	public void insertCourtDate(CourtEvents event) {
		CourtEventsDAO cDAO = DAOFactory.DEFAULT.getCourtEventsDAO();
		cDAO.makePersistent(event);		
	}

	public CourtEventType findCourtEventType(Integer typeCode) {
		CourtEventTypeDAO cetDAO = DAOFactory.DEFAULT.getCourtEventTypeDAO();
		//return cetDAO.findById(typeCode, false); 
		return cetDAO.findById(typeCode); 
	}

	public void insertCaseRecordHistory(CaseRecordHistory crh) {
		CaseRecordHistoryDAO crhDAO = DAOFactory.DEFAULT.getCaseRecordHistoryDAO();
		crhDAO.makePersistent(crh);
		
	}

	public CaseRecordEventType findCaseRecordEventType(Integer eventTypeCode) {
		CaseRecordEventTypeDAO crtDAO = DAOFactory.DEFAULT.getCaseRecordEventTypeDAO();
		//return crtDAO.findById(eventTypeCode, false);
		return crtDAO.findById(eventTypeCode);
		 
	}

	public void insertDocuments(Documents doc) {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		docDAO.makePersistent(doc);
		
	}

	public DocumentType findDocumentType(String typeDesc) {
		DocumentTypeDAO docTypeDAO = DAOFactory.DEFAULT.getDocumentTypeDAO();
		return docTypeDAO.findByTypeDescription(typeDesc);
	}
	
	public void insertFilingSearch(String docText, String docTitle, String docketID, String caseRecordUuid) {
		FilingSearchDAO fsDAO = DAOFactory.DEFAULT.getFilingSearchDAO();
		FilingSearch fs = new FilingSearch();
		fs.setDocketId(docketID);
		fs.setDocument(docText);
		fs.setDocumentTitle(docTitle);
		fs.setCaseRecordUuid(caseRecordUuid);
		fsDAO.makePersistent(fs);				
	}
	
	public List<FilingSearch> search(String fullText){
		FilingSearchDAO fsDAO = DAOFactory.DEFAULT.getFilingSearchDAO();
		return fsDAO.search(fullText);
	}
	
	public Person findPersonbyID(String personID) {
		PersonDAO pDAO = DAOFactory.DEFAULT.getPersonDAO();		 
		//return  pDAO.findById(personID, false); 
		return  pDAO.findById(personID);
	}

	public DocumentStatus findDocumentStatus(Integer statusCode) {
		DocumentStatusDAO dsDAO = DAOFactory.DEFAULT.getDocumentStatusDAO();
		//return dsDAO.findById(statusCode, false); 
		return dsDAO.findById(statusCode); 
	}
	
	public void insertFilingAudit(FilingAudit fa) {
		FilingAuditDAO faDAO = DAOFactory.DEFAULT.getFilingAuditDAO();
		faDAO.makePersistent(fa);
		
	}
	
	
	 
	public Profile makePersistenet(Profile profile) {
		ProfileDAO profileDAO = DAOFactory.DEFAULT.getProfileDAO();
		return profileDAO.makePersistent(profile);
	}

	public Signatures makePersistent(Signatures signatures) {
		LOG.info("1. Inside the makePersistent method for the siganture!!...");
		SignaturesDAO signaturesDAO = DAOFactory.DEFAULT.getSignaturesDAO();
		LOG.info("3. Inside the make Persistent signatureDAO where the pbject signaturesDAO is instantiated ..");
		return signaturesDAO.makePersistent(signatures);
	}
	/*
	public void updateXslContent(String code, byte[]xslContent){
		DocumentTypeDAO docTypeDAO = DAOFactory.DEFAULT.getDocumentTypeDAO();
		DocumentType docType = docTypeDAO.findById(code, true);
		docType.setStyleSheet(xslContent);
		docTypeDAO.makePersistent(docType);		
	} *
	
	public DocumentType findDocumentTypeByCode(String code){
		DocumentTypeDAO docTypeDAO = DAOFactory.DEFAULT.getDocumentTypeDAO();
		return docTypeDAO.findDocumentTypeByCode(code);
	}
	
	/*
	@SuppressWarnings("unchecked")
	public List<DocumentType> findDocumentTypesByAliasType() {
		
		DocumentTypeDAO docTypeDAO = DAOFactory.DEFAULT.getDocumentTypeDAO();
		List<DocumentType> docTypes = docTypeDAO.findDocumentTypesByAliasType();
		return docTypes;
		
	}
	
	/*
	public void insertSignature(byte[] sigValue,GregorianCalendar expirationDate,String personSigned, String doc) {
		SignaturesDAO sigDAO = DAOFactory.DEFAULT.getSignaturesDAO();
		sigDAO.insertSignature(sigValue,expirationDate,personSigned,doc);
	}
*/
	public void updateDocumentStatus(String uuid, DocumentStatus status) {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		//DocumentStatusDAO docStatusDAO = DAOFactory.DEFAULT.getDocumentStatusDAO();
		//docDAO.updateDocumentStatus(uuid, docStatusDAO.findById(statusCode, false));
		docDAO.updateDocumentStatus(uuid, status);
	}
	
	public CourtSeal findCourtSealByDocumentID(String documentID) {
		CourtSealDAO courtSealDAO = DAOFactory.DEFAULT.getCourtSealDAO();
		CourtSeal ce = courtSealDAO.findCourtSealByDocumentID(documentID);
		 return ce;
	}
	public Documents makePersistenet(Documents document) {
		DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		return documentsDAO.makePersistent(document);
	}
	
	public CourtSeal makePersistent(CourtSeal courtSeal) {
		CourtSealDAO courtSealDAO = DAOFactory.DEFAULT.getCourtSealDAO();
		return courtSealDAO.makePersistent(courtSeal);
	}
	
	//added by M Alexandrou 
	public List<Signatures> findSignaturesByDocumentsUuid(String docUuid) { 
         SignaturesDAO sgDAO = DAOFactory.DEFAULT.getSignaturesDAO();
         return sgDAO.findSignaturesByDocumentsUuid(docUuid); 
 }
	 
//	Frank added the following insertion methods    
    public void insertSignature(Signatures sig) { 
            SignaturesDAO sgDAO = DAOFactory.DEFAULT.getSignaturesDAO(); 
            sgDAO.makePersistent(sig); 
    }
    
    public void insertCourtSeal(CourtSeal courtSeal) { 
        CourtSealDAO csDAO = DAOFactory.DEFAULT.getCourtSealDAO(); 
        csDAO.makePersistent(courtSeal); 
    }	
    
    public List<Documents> findDocumentsbyMaxVersion(String caseRecordUuid){
    	DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return documentsDAO.findDocumentsbyMaxVersion(caseRecordUuid);
    }
    
    public List<Documents> getPDFDocuments(String caseRecordUuid){
    	DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return documentsDAO.getPDFDocuments(caseRecordUuid);
   }
    
    public Counter makePersistent(Counter counter) {
		CounterDAO counterDAO = DAOFactory.DEFAULT.getCounterDAO();
		return counterDAO.makePersistent(counter);
	}

    
    public Counter getCounter() {
    	LOG.info("about to create a counterDAO object .....");
		CounterDAO counterDAO = DAOFactory.DEFAULT.getCounterDAO();
		LOG.info("counterDAO object is created.....");
		return counterDAO.getCounter();
	}
  
    public void updateCounter(String counterUuid, int counterValue) {
    	CounterDAO counterDAO = DAOFactory.DEFAULT.getCounterDAO();
		counterDAO.updateCounter(counterUuid, counterValue);
	}
    
    
    public FilingAudit getFilingAudit(String crUuid) {
    	FilingAuditDAO filingAuditDAO = DAOFactory.DEFAULT.getFilingAuditDAO();
    	FilingAudit filingAudit = filingAuditDAO.findByCaseRecordUuid(crUuid);
    	return filingAudit;
    }

	/*public CounterPerSigner getCounterPerSigner() {
		LOG.info("about to create a counterPerSignerDAO object .....");
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		LOG.info("counterDAO object is created.....");
		return counterPerSignerDAO.getCounterPerSigner();
	} */

	public void makePersistent(CounterPerSigner counterPerSigner) {
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		counterPerSignerDAO.makePersistent(counterPerSigner);
	}

	public void updateCounterPerSigner(String counterUuid, int counterValue, Date dateOfLastSignature, String personUuid) {
		LOG.info("Inside the updateCounterPerSigner method of the MofelFacadeHibernate.java .....");
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		counterPerSignerDAO.updateCounterPerSigner(counterUuid, counterValue, dateOfLastSignature, personUuid);
	}

	public CounterPerSigner findCounterPerSignerBySignerUuid(String uuid) {
		LOG.info("Inside the findCounterPerSigner method  .....");
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		 return counterPerSignerDAO.findCounterPerSignerBySignerUuid(uuid);
	} 

	public boolean isSigner(String uuid) {
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		return counterPerSignerDAO.isSigner(uuid);
	}

	public void insertCounterPerSigner(CounterPerSigner counterPerSigner) {
		LOG.info("Inside the insertCounterPerSigner method of the ModelFacadeHibernate.java .....");
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		counterPerSignerDAO.makePersistent(counterPerSigner);
		LOG.info("persisting the "+counterPerSigner.getCounterUuid());
	}

	public String findCounterUuidBySignerUuid(String uuid) {
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		return counterPerSignerDAO.findCounterUuidBySignerUuid(uuid);
	}

	public void updateCounterPerSigner(String personUuid) {
		LOG.info("Inside the updateCounterPerSigner method of the ModelFacadHibernate  .....");
		CounterPerSignerDAO counterPerSignerDAO = DAOFactory.DEFAULT.getCounterPerSignerDAO();
		counterPerSignerDAO.updateCounterPerSigner(personUuid);
		
	}

	public boolean isSignaturesByDocumentsUuidAndPersonUuid(String docUuid, String personUuid) {
		LOG.info("Inside the findSignaturesByDocumentsUuidAndPersonUuid method of the ModelFacadHibernate  .....");
		 SignaturesDAO sgDAO = DAOFactory.DEFAULT.getSignaturesDAO();
         return sgDAO.isSignaturesByDocumentsUuidAndPersonUuid(docUuid, personUuid);	
    }	
	
	public List<Filing> findProgressingFilings(String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findProgressingFilings(); 
	}
	public List<Filing> findExistingFilings(String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findExistingFilings(); 
	}
	
	public List<Filing> findAttorneySideStatusFilings(String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAttorneySideStatusFilings();
	}
	
	public List<Filing> findCourtSideStatusFilings(String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCourtSideStatusFilings();
	}
	
	public List<String> getAllDescriptionsOfDocumentType() {
		DocumentTypeDAO docTypeDAO = DAOFactory.DEFAULT.getDocumentTypeDAO();
		List<DocumentType> docType = docTypeDAO.findAll();
		List<String> descriptions = new ArrayList<String>();
		for(int x=0;x<=docType.size()-1;x++){
			descriptions.set(x, docType.get(x).getDescription());
		}		
		return descriptions;
	}

	public DocumentType findDocTypeByDescription(String description) {
		DocumentTypeDAO docTypeDAO = DAOFactory.DEFAULT.getDocumentTypeDAO();
		return docTypeDAO.findByTypeDescription(description);
	}

	public Documents makePersistent(Documents document) {
		DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		return documentsDAO.makePersistent(document);
	}
	
	public List<Documents> findDocumentsByDocStatusCode(int code) {
		LOG.info("Inside the findDocummentsByDocStatusCode method of the ModelFacadeHibernate..");
		DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		return documentsDAO.findDocumentsByDocStatusCode(code);
	}

	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAllDocuments(int)
	 */
	public List<Documents> findAllDocuments(int record) {
		LOG.info("Inside the findAllDocuments in the ModelFacadeHibernate ....");
		DocumentsDAO documentsDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		List<Documents> documents = documentsDAO.findAll(record);
		return documents;	
	}

	public CaseRecordStatus findCaseRecordStatusByCode(int code) {
		LOG.info("Inside the findCaseRecordStatus in the ModelFacadeHibernate ....");
		CaseRecordStatusDAO caseRecordStatusDAO = DAOFactory.DEFAULT.getCaseRecordStatusDAO();
		CaseRecordStatus caseRecordStatus = caseRecordStatusDAO.findCaseRecordStatusByCode(code);
		return caseRecordStatus;	
	}

	public CaseRecordType findCaseRecordTypeByCode(int code) {
		LOG.info("Inside the findCaseRecordType in the ModelFacadeHibernate ....");
		CaseRecordTypeDAO caseRecordTypeDAO = DAOFactory.DEFAULT.getCaseRecordTypeDAO();
		CaseRecordType caseRecordType = caseRecordTypeDAO.findCaseRecordTypeByCode(code);
		return caseRecordType;	
	}

	public Court findCourtByUuid(String uuid) {
		CourtDAO courtDAO = DAOFactory.DEFAULT.getCourtDAO();
		//Court court = courtDAO.findById(uuid, true);
		Court court = courtDAO.findCourtByUuid(uuid);	
		return court;
	}

	public CaseRecord findCaseRecordByExternalCaseRecordUuidAndExternalCaseTypeCode(String externaCaseRecordUuid, int ocssCaseTypeCode, String courtUuid) {
		throw new UnsupportedOperationException("findCaseRecordByExternalCaseRecordUuidAndExternalCaseTypeCode not supported");
		/*
		LOG.info("Inside the findCaseRecordByExternalCaseRecordUuidAndExternalCaseTypeCode method of ModelFacadeHibernate ..");
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		LOG.info("Invoking findCaseRecordByExternalCaseRecordUuidAndExternalCaseTypeCode method of the caseRecordDAOHibrnate");
		CaseRecord caseRecord = caseRecordDAO.findCaseRecordByExternalCaseRecordUuidAndExternalCaseTypeCode(externaCaseRecordUuid, ocssCaseTypeCode);
		return caseRecord;
		*/
	}

	public List<CaseRecordIdExternalCaseRecordNumber> findExternalCaseRecordNumbers(String caseRecordUuid) {
		CaseRecordExternalCaseRecordNumberDAO caseRecordExternalCaseRecordNumberDAO 
			= DAOFactory.DEFAULT.getCaseRecordExternalCaseRecordNumberDAO();
		return caseRecordExternalCaseRecordNumberDAO.findExternalCaseRecordNumbers(caseRecordUuid);
	}
	/*public void insertExternalCaseRecordToCaseRecord(String externalCaseRecordUuid, CaseRecord caseRecord, int ocssCaseTypeCode) {
		LOG.info("Inside the insertExternalCaseRecord method of the ModelFacadeHibernate...");
		ExternalCaseRecordToCaseRecordDAO externalCaseRecordToCaseRecordDA0 = DAOFactory.DEFAULT.getExternalCaseRecordToCaseRecordDAO();
		externalCaseRecordToCaseRecordDA0.insertExternalCaseRecordToCaseRecord(externalCaseRecordUuid, caseRecord, ocssCaseTypeCode);
		
		
	}*/

	public boolean isExternalCaseRecordUuidAndExternalCaseTypeCode(String externalCaseRecordUuid, int externalCaseTypeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);				
		return caseRecordDAO.isExternalCaseRecordUuidAndExternalCaseTypeCode(externalCaseRecordUuid, externalCaseTypeCode);
		//return false;
	}

	public void insertExternalCaseRecordIntoCaseRecordTable(String  caseRecordUuid, String externalCaseRecordUuid, int externalCaseTypeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		caseRecordDAO.insertExternalCaseRecordIntoCaseRecordTable(caseRecordUuid, externalCaseRecordUuid, externalCaseTypeCode);
		
	}

	
	public DocumentSigConfig findCoordinatesByCodeRole(String personRole, String documentCode) {
		DocumentSigConfigDAO dscDAO = DAOFactory.DEFAULT.getDocumentSigConfigDAO();
		DocumentSigConfig dsconfig = dscDAO.findCoordinatesByPersonRole(personRole, documentCode);
		return dsconfig;
	}

	public void insertCourtEvents(CourtEvents courtEvent) {
		CourtEventsDAO ceDAO = DAOFactory.DEFAULT.getCourtEventsDAO();
		ceDAO.makePersistent(courtEvent);		
		
	}
	
	public List<Filing> findAllFilingsByTypeForAdmin(int typeCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAllFilingsByTypeForAdmin(typeCode);
	}
	
	public List<Filing> findAllFilingsByTypeForClerk(int typeCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAllFilingsByTypeForClerk(typeCode);
	}
	
	public List<Filing> findAllFilingsByTypeForJudge(int typeCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAllFilingsByTypeForJudge(typeCode);
	}

	public Attorney findAttorneyByLegalPreparerUuid(String personUuid) {
		LegalPreparerDAO legalPreparerDAO = DAOFactory.DEFAULT.getLegalPreparerDAO();		
		return legalPreparerDAO.findAttorneyByLegalPreparerUuid(personUuid);
	}

	@Deprecated
	public Person findPersonByAttorneyUuid(String attorneyUuid) {
		LegalPreparerDAO legalPreparerDAO = DAOFactory.DEFAULT.getLegalPreparerDAO();
		return legalPreparerDAO.findPersonByAttorneyUuid(attorneyUuid);
	}
	
	public Attorney findAttorneyByPerson(Person person) {
		AttorneyDAO attorneyDAO = DAOFactory.DEFAULT.getAttorneyDAO();
		return attorneyDAO.findAttorneyByPerson(person);
	}
	
	public Attorney findAttorneyByPersonAndOrganization(Person person,Organizations c)
	{
		AttorneyDAO attorneyDAO = DAOFactory.DEFAULT.getAttorneyDAO();
		return attorneyDAO.findAttorneyByPersonAndOrganization(person,c);
	}

	public void removeDocumentFromListByCaseRecordUuidAndDocumentInstanceCode(String documentTypeCode, String caseRecordUuid) {
		LOG.info("Inside the Model Hibernate ...");
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		docDAO.removeDocumentFromListByCaseRecordUuidAndDocumentInstanceCode(documentTypeCode, caseRecordUuid);
	}
	public void deleteDocument(Documents doc) {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		docDAO.deleteDocument(doc);
	}
	
	public void enableDocDeleteFlag(Documents doc) {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		docDAO.enableDocDeleteFlag(doc);
	}
	
	
	public LdapDirectoryPerson findLdapDirectoryByPerson(Person person) {
		LdapDirectoryPersonDAO ldPersonDAO = DAOFactory.DEFAULT.getLdapDirectoryPersonDAO();
		return ldPersonDAO.findLdapDirectoryByPerson(person);
	}	
	
	public DocumentPackage findPackageNameByUuid(String uuid) {
		DocumentPackageDAO dpDAO = DAOFactory.DEFAULT.getDocumentPackageDAO();
		return dpDAO.findPackageNameByUuid(uuid);
	}
	
	public DocumentPackage findDocumentPackageByName(String name) {
		DocumentPackageDAO dpDAO = DAOFactory.DEFAULT.getDocumentPackageDAO();
		return dpDAO.findDocumentPackageByName(name);
	}
	
	public List<DocPageRange> findAllPageRangeByPackageUuid(DocumentPackage dp) {
		DocPageRangeDAO dprDAO = DAOFactory.DEFAULT.getDocPageRangeDAO();
		return dprDAO.findAllPageRangeByPackageUuid(dp);
	}
	public DocumentType findDocTypeByRangePackageUuid(int start, int end, DocumentPackage dp) {
		DocPageRangeDAO dprDAO = DAOFactory.DEFAULT.getDocPageRangeDAO();
		return dprDAO.findDocTypeByRangePackageUuid(start, end, dp);
	}
	public DocumentType findDocTypeByUuid(String uuid) {
		DocPageRangeDAO dprDAO = DAOFactory.DEFAULT.getDocPageRangeDAO();
		return dprDAO.findDocTypeByUuid(uuid);
	}
	public List<Filing> findClearedCaseFilingsAgentSide(String courtUuid){
		CaseRecordDAO caseRecordDAO =DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findClearedCaseFilingsAgentSide();
	}
	
	public List<Filing> findClearedCaseFilingsClerkSide(String courtUuid){
		CaseRecordDAO caseRecordDAO =DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findClearedCaseFilingsClerkSide();
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getPersonParicipant(us.gaaoc.framework.model.CaseRecord)
	 */
	public List<PersonParticipants> getPersonParicipant(CaseRecord caseRecord) {
		PersonParticipantsDAO ppDAO =DAOFactory.DEFAULT.getPersonParticipantsDAO();
		return ppDAO.getPersonParicipant(caseRecord);
		
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#deletePerson(us.gaaoc.framework.model.Person)
	 */
	public void deletePerson(Person person) {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		personDAO.deletePerson(person);
		
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#deletePersonParticipants(us.gaaoc.framework.model.CaseRecord)
	 */
	public void deletePersonParticipants(PersonParticipants pp) {
		PersonParticipantsDAO ppDAO = DAOFactory.DEFAULT.getPersonParticipantsDAO();
		ppDAO.deletePersonParticipants(pp);
		
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findCaseRecordByPerson(us.gaaoc.framework.model.Person)
	 */
	public List<CaseRecord> findCaseRecordsByPerson(Person personParticipant) {
		PersonParticipantsDAO ppDAO =DAOFactory.DEFAULT.getPersonParticipantsDAO();
		return ppDAO.findCaseRecordsByPerson(personParticipant);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#deleteCourtEvent(us.gaaoc.framework.model.CaseRecord)
	 */
	public void deleteCourtEvent(CaseRecord record) {
		CourtEventsDAO ceDAO = DAOFactory.DEFAULT.getCourtEventsDAO();
		ceDAO.deleteCourtEvent(record);		
	}

	public void deleteCaseRecord(String caseUuid, String courtUuid) {
		CaseRecordDAO crDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		crDAO.deleteCaseRecord(caseUuid);		
	}

	public List<DocumentInstance> findDocumentInstanceByAliasType() {
		
		DocumentInstanceDAO docInstanceDAO = DAOFactory.DEFAULT.getDocumentInstanceDAO();
		List<DocumentInstance> docTypes = docInstanceDAO.findDocumentInstanceByAliasType();
		return docTypes;
		
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findDocumentInstanceByCode(java.lang.String)
	 */
	public DocumentInstance findDocumentInstanceByCode(int docTypeCode) {
		DocumentInstanceDAO docInstanceDAO = DAOFactory.DEFAULT.getDocumentInstanceDAO();
		//return docInstanceDAO.findById(docTypeCode, false); 
		return docInstanceDAO.findById(docTypeCode); 
	
	}

 
	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findDocumentInstanceByAliasType(us.gaaoc.framework.model.Court)
	 */
	public List<DocumentInstance> findDocumentInstanceByAliasType(Court court) {
		DocumentInstanceDAO docInstanceDAO = DAOFactory.DEFAULT.getDocumentInstanceDAO();
		return docInstanceDAO.findDocumentInstanceByAliasType(court);
	}
	
	
	

	public LocalCaseCategory findLocalCaseCategoryByCourtandCode(Court court, String cmsCode) {
		LocalCaseCategoryDAO localCaseCategoryDAO = DAOFactory.DEFAULT.getLocalCaseCategoryDAO();		
		return localCaseCategoryDAO.findLocalCaseCategoryByCourtandCode(court, cmsCode);
	}

	public LocalCaseDivision findLocalCaseDivisionByCourtandCode(Court court, String cmsCode) {
		LocalCaseDivisionDAO localCaseDivisionDAO = DAOFactory.DEFAULT.getLocalCaseDivisionDAO();		
		return localCaseDivisionDAO.findLocalCaseDivisionByCourtandCode(court, cmsCode);
	}

	public LocalCaseFilingType findLocalCaseFilingTypeByCourtandCode(Court court, String cmsCode) {
		 LocalCaseFilingTypeDAO lcftDAO = DAOFactory.DEFAULT.getLocalCaseFilingTypeDAO();
		 return lcftDAO.findLocalCaseFilingTypeByCourtandCode(court, cmsCode);
	}

	public LocalCaseType findLocalCaseTypeByCourtandCode(Court court, String cmsCode) {
		LocalCaseTypeDAO lctDAO = DAOFactory.DEFAULT.getLocalCaseTypeDAO();
		return lctDAO.findLocalCaseTypeByCourtandCode(court, cmsCode); 
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findDocumentPackageByAliasType(us.gaaoc.framework.model.Court)
	 */
	public List<DocumentPackage> findDocumentPackageByAliasType(Court court) {
		DocumentPackageDAO docPackageDAO = DAOFactory.DEFAULT.getDocumentPackageDAO();
		return docPackageDAO.findDocumentPackageByName(court);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getDocumentSigConfig(int)
	 */
	public DocumentSigConfig getDocumentSigConfig(int documentCode,  Person personSigned) {
		DocumentSigConfigDAO documentSigConfigDAO = DAOFactory.DEFAULT.getDocumentSigConfigDAO();
		return documentSigConfigDAO.getDocumentSigConfig(documentCode, personSigned);
	}

	public LocalParticipantRelationship findLocalParticipantRelationship(Court court, int participantRelationshipCode) {
		LocalParticipantRelationshipDAO lprsDAO = DAOFactory.DEFAULT.getLocalParicipantRelationshipDAO();
		return lprsDAO.findLocalParticipantRelationship(court, participantRelationshipCode);
	}

	public LocalCourtEventType findLocalCourtEventType(Court court, int courtEventTypeCode) {
		LocalCourtEventTypeDAO lcetDAO = DAOFactory.DEFAULT.getLocalCourtEventTypeDAO();
		return lcetDAO.findLocalCourtEventType(court, courtEventTypeCode);
	}

	public Signatures findSignatureFromSignatureTrackingID(String sigTrackingId) {
		SignaturesDAO sigDAO = DAOFactory.DEFAULT.getSignaturesDAO();
		return sigDAO.findSignatureFromSignatureTrackingID(sigTrackingId);
	}


	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAttorneySubmissionDate(java.lang.String)
	 */
	public Date findAttorneySubmissionDate(String caseRecordUuid) {
		CaseRecordHistoryDAO carhDAO = DAOFactory.DEFAULT.getCaseRecordHistoryDAO();
		return carhDAO.findAttorneySubmissionDate(caseRecordUuid);
	}

	public DocumentInstance findGenericDocumentInstance(String localCode, Court court) {
		DocumentInstanceDAO diDAO = DAOFactory.DEFAULT.getDocumentInstanceDAO();
		return diDAO.findGenericDocumentInstance(localCode, court);
	}

	public void insertIntoCaseRecordIdExternalCaseRecordNumber(CaseRecord caseRecord, String externalCaseRecordNumber, Organizations org) {
		CaseRecordExternalCaseRecordNumberDAO caseRecordExternalCaseRecordNumberDAO = DAOFactory.DEFAULT.getCaseRecordExternalCaseRecordNumberDAO();
		caseRecordExternalCaseRecordNumberDAO.insertIntoCaseRecordIdExternalCaseRecordNumber(caseRecord, externalCaseRecordNumber, org);
		
	}

	public List<CaseRecord> findCaseRecordListByExternalCaseRecordNumber(String externalCaseRecordNummber) {
		CaseRecordExternalCaseRecordNumberDAO caseRecordExternalCaseRecordNumberDAO = DAOFactory.DEFAULT.getCaseRecordExternalCaseRecordNumberDAO();
		return caseRecordExternalCaseRecordNumberDAO.findCaseRecordListByExternalCaseRecordNumber(externalCaseRecordNummber);
	}

	public List<Filing> findFilingsByExternalCaseRecordNumber(String externalCaseRecordNumber, String courtUuid) {
		CaseRecordDAO caseRecordDAO =DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findFilingsByExternalCaseRecordNumber(externalCaseRecordNumber);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findNumberOfCaseFilingsByTypeAndStatus(int, int[])
	 */
	public int findNumberOfCaseFilingsByTypeAndStatus(int typeCode, int statusCode1, int statusCode2, int statusCode3, int statusCode4, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfCaseFilingsByTypeAndStatus(typeCode, statusCode1, statusCode2, statusCode3, statusCode4);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findCaseFilingsByTypeAndStatusPaged(int, int, int, int, int, int)
	 */
	public List<Filing> findCaseFilingsByTypeAndStatus(int typeCode, int statusCode1, int statusCode2, int statusCode3, int statusCode4, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsByTypeAndStatus(typeCode, statusCode1, statusCode2, statusCode3, statusCode4);
	}

	public Person findPersonByHashedSSN(String ssn) {
		PersonHashedSSNDAO personHashedSSNDAO = DAOFactory.DEFAULT.getPersonHashedSSNDAO();
		return personHashedSSNDAO.findPersonByHashedSSN(ssn);
		
	}
	
	//Added by Frank
	public List<Filing> findCaseFilingsByPerson(String firstName, String middleName, String lastName, boolean defendantSearch, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsByPerson(firstName, middleName, lastName, defendantSearch);		
	}
	
	public List<Filing> findCaseFilingsByPerson(String firstName,
			String middleName, String lastName, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsByPerson(firstName, middleName, lastName);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findNumberOfCaseFilingsByType(int)
	 */
	public int findNumberOfCaseFilingsByType(int typeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfCaseFilingsByType(typeCode);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findCaseFilingsByTypePaged(int, int, int)
	 */
	public List<Filing> findCaseFilingsByTypePaged(int caseType, int startRow, int pageSize, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsByTypeAndStatus(caseType, startRow, pageSize);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findCaseFilingsByTypeAndStatusPaged(int, int, int, int, int, int)
	 */
	public List<Filing> findCaseFilingsByTypeAndStatusPaged(int caseType, int status1, int status2, int status3,int status4, int startRow, int pageSize, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsByTypeAndStatusPaged(caseType, status1, status2, status3, status4, startRow, pageSize);
	}

	public List<Filing> findFilingByCaseTrackingId(String caseTrackingId, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findFilingByCaseTrackingId(caseTrackingId);
	}

	public void insertIntoPersonIdHashedSSN(String personUuid, String hashedSSN) {		
		PersonHashedSSNDAO personHSSNDAO = DAOFactory.DEFAULT.getPersonHashedSSNDAO();
		personHSSNDAO.insertIntoPersonIdHashedSSN(personUuid, hashedSSN);
		
	}

	public List<Person> findPersonListByNameAndByDOB(String firstName, String middleName, String lastName, Date dateOfBirth) {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO.findPersonListByNameAndByDOB(firstName, middleName, lastName, dateOfBirth);
	} 

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAllFilingsByTypeForClerkPaged(int, int, int)
	 */
	public List<Filing> findAllFilingsByTypeForClerkPaged(int typeCode, int startRow, int pageSize, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAllFilingsByTypeForClerkPaged(typeCode, startRow, pageSize);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAllFilingsByTypeForJudgePage(int, int, int)
	 */
	public List<Filing> findAllFilingsByTypeForJudgePage(int typeCode, int startRow, int pageSize, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAllFilingsByTypeForJudgePaged(typeCode, startRow, pageSize);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findNumberOfCaseFilingsByTypeForClerk(int)
	 */
	public int findNumberOfCaseFilingsByTypeForClerk(int typeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfCaseFilingsByTypeForClerk(typeCode);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findNumberOfCaseFilingsByTypeForJudge(int)
	 */
	public int findNumberOfCaseFilingsByTypeForJudge(int typeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfCaseFilingsByTypeForJudge(typeCode);
	}

	public int findNumberOfCaseFilingsByTypeForAdmin(int typeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfCaseFilingsByTypeForAdmin(typeCode);
	}

	public List<Filing> findCaseFilingsForPastDays(Date startingDate, Date endingDate, String personLoginUuid, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsForPastDays(startingDate, endingDate, personLoginUuid);
	}
	
	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAddressCateory(us.gaaoc.framework.model.AddressCategory)
	 */
	public AddressCategory findAddressCateory(int addressCategoryCode) {
		AddressCategoryDAO addressCategoryDAO = DAOFactory.DEFAULT.getAddressCategoryDAO();
		return addressCategoryDAO.findAddressCateory(addressCategoryCode);
	}

	
	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAddressType(int, us.gaaoc.framework.model.AddressCategory)
	 */
	public AddressType findAddressType(int addressTypeCode,
			AddressCategory addressCategory) {
		AddressTypeDAO addressTypeDAO = DAOFactory.DEFAULT.getAddressTypeDAO();
		return addressTypeDAO.findAddressType(addressTypeCode,addressCategory);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAddressCateory(java.lang.String, us.gaaoc.framework.model.AddressType)
	 */
	public Address findAddress(Person person, AddressType addressType) {
		PersonAddressDAO personAddressDAO = DAOFactory.DEFAULT.getPersonAddressDAO();
		return personAddressDAO.findAddress(person,addressType);

	}
	public Address findAddressExactMatch(Address address) {
		AddressDAO addressDAO = DAOFactory.DEFAULT.getAddressDAO();
		return addressDAO.findAddressExactMatch(address);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#createCaseRecord(java.util.Date, java.util.Date, us.gaaoc.framework.model.CaseRecordStatus, us.gaaoc.framework.model.CaseRecordType, us.gaaoc.framework.model.Court, us.gaaoc.framework.model.LocalCaseCategory, us.gaaoc.framework.model.LocalCaseDivision, us.gaaoc.framework.model.LocalCaseFilingType, us.gaaoc.framework.model.LocalCaseType)
	 */
	public CaseRecord createCaseRecord(Date instanciationDate,
			Date submittedDate, CaseRecordStatus crSt, CaseRecordType crT,
			Court c, LocalCaseCategory localCaseCategory,
			LocalCaseDivision localCaseDivision,
			LocalCaseFilingType localCaseFilingType, LocalCaseType localCaseType, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.createCaseRecord(instanciationDate,submittedDate,crSt,crT,c,localCaseCategory,localCaseDivision,localCaseFilingType,localCaseType);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findOrganization(us.gaaoc.framework.model.Organizations, java.lang.String)
	 */
	public Organizations findOrganization(Organizations orgFound, String street1) {
		OrganizationsDAO oDAO = DAOFactory.DEFAULT.getOrganizationsDAO();
		return oDAO.findOrganization(orgFound, street1);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#insertAddress(us.gaaoc.framework.model.Address)
	 */
	public void insertAddress(Address addr) {
		AddressDAO addressDAO = DAOFactory.DEFAULT.getAddressDAO();
		addressDAO.makePersistent(addr);
		
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#updatePersonAddress(us.gaaoc.framework.model.Person, us.gaaoc.framework.model.Address, us.gaaoc.framework.model.PersonAddress)
	 */
	public void updateAddress( Address address,
			PersonAddress personAddress) {
		AddressDAO addressDAO = DAOFactory.DEFAULT.getAddressDAO();
		addressDAO.updateAddress(address,personAddress);
	}
	public int updatePersonAddressType(String personAddressUuid, 
			AddressType addressType) {
		PersonAddressDAO personAddressDAO = DAOFactory.DEFAULT
			.getPersonAddressDAO();
		return personAddressDAO.updatePersonAddressType(personAddressUuid, addressType);
	}
	public List<String> findCaseFilingsWithinDateRange(Date startingDate, Date endingDate, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findCaseFilingsWithinDateRange(startingDate, endingDate);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#makePersistent(us.gaaoc.framework.model.PersonHashedSSN)
	 */
	public void makePersistent(PersonHashedSSN personHashedSSN) {
		PersonHashedSSNDAO personHashedSSNDAO = DAOFactory.DEFAULT.getPersonHashedSSNDAO();
		personHashedSSNDAO.makePersistent(personHashedSSN);		
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getVisualMark(us.gaaoc.framework.model.Person)
	 */
	public VisualMark getVisualMark(Person personSigner, boolean altSigFlag,VisualMarkCategory visualCategory) {
		VisualMarkDAO visualMarkDAO = DAOFactory.DEFAULT.getVisualMarkDAO();
		return visualMarkDAO.getVisualMark(personSigner,altSigFlag, visualCategory);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getVisualMarkList(us.gaaoc.framework.model.Person, boolean)
	 */
	public List<VisualMark> getVisualMarkList(Person personSigner,
			boolean altSigFlag,VisualMarkCategory visualCategory) {
		VisualMarkDAO visualMarkDAO = DAOFactory.DEFAULT.getVisualMarkDAO();
		return visualMarkDAO.getVisualMarkList(personSigner,altSigFlag,visualCategory);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getVisualCategory(int)
	 */
	public VisualMarkCategory getVisualCategory(int visualCategoryCode) {
		VisualMarkCategoryDAO visualMarkCategoryDAO = DAOFactory.DEFAULT.getVisualMarkCategoryDAO();
		return visualMarkCategoryDAO.getVisualMarkCategory(visualCategoryCode);
	}	
	
	/**
	 * This query returns a local document code for a given court and a given document instance
	 * @param documentInstanceCode
	 * @param courtUuid
	 * @return
	 */
	public DocumentLocalCode findDocumentLocalCodeFromDocumentInstanceCode(
			int documentInstanceCode) {
		DocumentLocalCodeDAO docLocalCodeDAO = DAOFactory.DEFAULT.getDocumentLocalCodeDAO();
		return docLocalCodeDAO.findDocumentLocalCodeFromDocumentInstanceCode(documentInstanceCode);
	}

	public int findTheNumberOfDocumentsAlreadyImportedIntoCMSOfACaseRecord(
			CaseRecord caseRecord) {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		return docDAO.findTheNumberOfDocumentsAlreadyImportedIntoCMSOfACaseRecord(caseRecord);
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getDocumentTypeList(int)
	 */
	public List<DocumentType> getDocumentTypeList(int docCategoryCode) {
		DocumentTypeDAO docTypeDAO = DAOFactory.DEFAULT.getDocumentTypeDAO();
		return docTypeDAO.getDocumentTypeList(docCategoryCode);
	}
	
	public LdapDirectoryOrganization findLdapDirectoryByOrganization(Court court) {
	//public LdapDirectoryOrganization findLdapDirectoryByOrganization(Organizations court) {
		LdapDirectoryOrganizationDAO ldOrganizationDAO = DAOFactory.DEFAULT.getLdapDirectoryOrganizationDAO();
		return ldOrganizationDAO.findLdapDirectoryByOrganization(court);
	}

	public PersonAddress findPersonAddress(Person personFound) {
		PersonAddressDAO paDAO = DAOFactory.DEFAULT.getPersonAddressDAO();
		return paDAO.findPersonAddress(personFound); 
	}
	
	
	/**
	 * get the initiating organization(s) in a case
	 * @param caseRecord
	 * @return the list of initiating organizations
	 */
	public List<OrgParticipants> getOrgParticipantInitiatingParty(CaseRecord caseRecord) {
		OrgParticipantsDAO orgPartDAO = DAOFactory.DEFAULT.getOrgParticipantsDAO();		
		return orgPartDAO.getOrgParticipantInitiatingParty(caseRecord);
	}
	
	
	
	/**
	 * get the participant(s) in a case
	 * @param caseRecord
	 * @return list of participants
	 */
	public List<PersonParticipants> getPersonParticipantByParticipantRelationshipCode(CaseRecord caseRecord, int participantRelationshipCode) {
		PersonParticipantsDAO pp = DAOFactory.DEFAULT.getPersonParticipantsDAO();
		return pp.getPersonParticipantByParticipantRelationshipCode(caseRecord, participantRelationshipCode);
	}
	
	/**
	 * Get a list of strings of descriptions of a case record statuses
	 * One use of this list is in the creation of UISelectItem uiItems to populate a list box.
	 * A user can then select a description for possible modification of the status of a case
	 * @return a list of descriptions
	 */
	public List<String> getCaseRecordStatusDescriptionList() {
		CaseRecordStatusDAO crs = DAOFactory.DEFAULT.getCaseRecordStatusDAO();		
		return crs.getCaseRecordStatusDescriptionList();
	}

	public int findCaseRecordStatusCode(String caseRecordStatusDescription) {
		CaseRecordStatusDAO crs = DAOFactory.DEFAULT.getCaseRecordStatusDAO();
		return crs.findCaseRecordStatusCode(caseRecordStatusDescription);
	}
	/**
	 * change the status of a case record
	 * @param caseReocrd
	 * @param caseRecordStatusCode
	 */
	public void UpdateCaseRecordByStatus(CaseRecord caseReocrd, CaseRecordStatus caseRecordStatus, String courtUuid){
		CaseRecordDAO crDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		crDAO.UpdateCaseRecordByStatus(caseReocrd, caseRecordStatus);
		
	}
	
	/**
	 * Get a list of strings of descriptions of a document statuses
	 * One use of this list is in the creation of UISelectItem uiItems to populate a list box.
	 * A user can then select a description for possible modification of the status of a document
	 * @return a list of descriptions
	 */
	public List<String> getDocumentStatusDescriptionList() {
		DocumentStatusDAO ds = DAOFactory.DEFAULT.getDocumentStatusDAO();		
		return ds.getDocumentStatusDescriptionList();
	}

	public int findDocumentStatusCode(String documentStatusDescription) {
		DocumentStatusDAO csDAO = DAOFactory.DEFAULT.getDocumentStatusDAO();
		return csDAO.findDocumentStatusCode(documentStatusDescription);
	}
	
	/**
	 * @param docUuid
	 * @param docStatus
	 * One possible use of this method is from the admin module where an authorized 
	 * administrator changes the status of a document
	 */
	public void UpdateDocumentByStatus(String docUuid, DocumentStatus docStatus) {
		DocumentsDAO dDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		dDAO.UpdateDocumentByStatus(docUuid, docStatus);
		
	}
	
	/**
	 * @param typeCode
	 * @return the filings that are flagged as cleared
	 * One possible use of this method is from the admin module where an authorized administrator
	 * sees all the cleared filings and decides to restore one or more of them
	 */
	public List<Filing> findAllClearedFilings(int typeCode, String courtUuid){
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		List<Filing> filings = caseRecordDAO.findAllClearedFilings(typeCode);
		return filings;
	}

	public void UpdateFilingByClearFilingFlag(int typeCode,
			String caseRecordUuid, boolean clearFilingFlag, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		caseRecordDAO.UpdateFilingByClearFilingFlag(typeCode, caseRecordUuid, clearFilingFlag);
		
		
	}

	public int findNumberOfClearedFilingsByType(int typeCode, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfClearedFilingsByType(typeCode);
	}
	
	/**
	 * Method to get all cases of a certain case type and of two certain statuses
	 * In the application frequently we query the data base by the "filing" view that includes info 
	 * from the participants table also. That results in the application to break if a case record is created 
	 * with no participants
	 */
	public List<CaseRecord> findAllCaseRecordsByCaseTypeAndStatus(
			int caseTypeCode, int statusCode1, int statusCode2, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findAllCaseRecordsByCaseTypeAndStatus(caseTypeCode, statusCode1, statusCode2);
	}
	
	public int findNumberOfAllCaseRecordsByCaseTypeAndStatus(int typeCode, int statusCode1, int statusCode2, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.findNumberOfAllCaseRecordsByCaseTypeAndStatus(typeCode, statusCode1, statusCode2);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#sortFiling(int, int, int, int, int, boolean, boolean)
	 */
	public List<Filing> sortFiling(int typeCode, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4, boolean desc,
			boolean orderByEvt, String personalCases, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.sortFiling(typeCode, statusCode1, statusCode2,
				statusCode3, statusCode4, desc, orderByEvt, personalCases);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#sortFiling(int, int, int, int, int, int, boolean, boolean)
	 */
	public List<Filing> sortFiling(int typeCode, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4, int statusCode5,
			boolean desc, boolean orderByEvt, String personalCases, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.sortFiling(typeCode, statusCode1, statusCode2,
				statusCode3, statusCode4, statusCode5, desc, orderByEvt,
				personalCases);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#sortFilingPaged(int, int, int, int, boolean, boolean, String, int, int)
	 */
	public List<Filing> sortFilingPaged(int caseType, int statusCode1, 
			int statusCode2, int statusCode3, int statusCode4, boolean desc,
			boolean orderByEvt, int startRow, String personalCases,
			int pageSize, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.sortFilingPaged(caseType, statusCode1,
				statusCode2, statusCode3, statusCode4, desc, orderByEvt,
				startRow, personalCases, pageSize);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#sortFilingPaged(int, int, int, int, int, boolean, boolean, int, int)
	 */
	public List<Filing> sortFilingPaged(int caseType, int statusCode1, 
			int statusCode2, int statusCode3, int statusCode4, int statusCode5,
			boolean desc, boolean orderByEvt, int startRow,
			String personalCases, int pageSize, String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.sortFilingPaged(caseType, statusCode1,
				statusCode2, statusCode3, statusCode4, statusCode5, desc,
				orderByEvt,	startRow, personalCases, pageSize);
	}
	
//CaseStatistics
	
	public int countCaseRecords(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.countCaseRecords();
	}


	public int countContemptCases(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.countContemptCases();
	}
	

		public List<CaseRecordsCountPerDay> countCasesByDay(String courtUuid) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return caseRecordDAO.countCasesByDay();
	}

		public List<CaseRecordsCountPerMonth> countCasesByMonth(String courtUuid) {
			CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
			return caseRecordDAO.countCasesByMonth();
		}

	public int countLocalCases(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.countLocalCases();
	}

	public int countEstablishedCases(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.countEstablishedCases();
	}


	//Signature Statistics
	public int CountSignaturesByAttorney() {
		SignaturesDAO sigDAO = DAOFactory.DEFAULT.getSignaturesDAO();
		return sigDAO.CountSignaturesByAttorney();
	}

	public int countSignatureByCourtClerk() {
		SignaturesDAO sigDAO = DAOFactory.DEFAULT.getSignaturesDAO();
		return sigDAO.countSignatureByCourtClerk();
	}
	public int countSignatures() {
		SignaturesDAO sigDAO = DAOFactory.DEFAULT.getSignaturesDAO();
		return sigDAO.countSignatures();
	}
	public int countSignaturesByJudge() {
		// TODO Auto-generated method stub
		SignaturesDAO sigDAO = DAOFactory.DEFAULT.getSignaturesDAO();
		return sigDAO.countSignaturesByJudge();
	}
	
	//Person Statistics

	public int countChildren() {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO.countChildren();
	}

	public int countDefendents() {
		PersonDAO personDAO = DAOFactory.DEFAULT.getPersonDAO();
		return personDAO. countDefendents();
	}
   
	
	//Documents Statistics
	/*	public int countDocuments() {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return docDAO.countDocuments();	
	}

	public int countDocumentsByCategoryExcludingDataFiles() {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return docDAO.countDocumentsByCategoryExcludingDataFiles();
	}

	public int countDocumentsByMonth() {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return docDAO.countDocumentsByMonth();
	}

	public int countNumberOfDocumentsByCategoryAndTypeExcludingDataFiles() {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return docDAO.countNumberOfDocumentsByCategoryAndTypeExcludingDataFiles();
	}*/
	public int countDocuments() {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return docDAO.countDocuments();	
	}

	

	public List<DocumentsCountPerMonth> countDocumentsByMonth() {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return docDAO.countDocumentsByMonth();
	}

	public List<DocumentsCountByType> countDocumentsByType() {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		 return docDAO.countDocumentsByType();
	
	}

	 //Filing Statistics
	
	public int countFilings(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.countFilings();
	}

	public int countProcessedFiling(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.countProcessedFiling();
	}

	//Dismissed Cases

	public List<DismissedCases> findDismissedCases(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.findDismissedCases();
		
	}

	public List<DismissedCasesPerMonth> countDismissedCasesPerMonth(String courtUuid) {
		CaseRecordDAO docDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return docDAO.countDismissedCasesPerMonth();
	
	}
	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getTextDocument(java.lang.String)
	 */
	public Documents getTextDocument(String caseUuid) {
		DocumentsDAO docDAO = DAOFactory.DEFAULT.getDocumentsDAO();
		return docDAO.getTextDocument(caseUuid);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findAllDocumentBinaries(int)
	 */
	public List<DocumentBinaries> findAllDocumentBinaries(int rowNumber) {
		DocumentBinariesDAO binaryDAO = DAOFactory.DEFAULT.getDocumentBinariesDAO();
		return binaryDAO.findAllDocumentBinaries(rowNumber);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#updateDocumentBinaryPath(java.lang.String, java.lang.String)
	 */
	public void updateDocumentBinaryPath(String uuid, String path) {
		DocumentBinariesDAO binaryDAO = DAOFactory.DEFAULT.getDocumentBinariesDAO();
		binaryDAO.updateDocumentBinaryPath(uuid, path);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findDocumentBinaryByUuid(java.lang.String)
	 */
	public DocumentBinaries findDocumentBinaryByUuid(String uuid) {
		DocumentBinariesDAO binaryDAO = DAOFactory.DEFAULT.getDocumentBinariesDAO();
		return binaryDAO.findDocumentBinaryByUuid(uuid);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#insertDocumentBinaries(java.lang.String, java.lang.String, int, java.lang.String)
	 */
	public void insertDocumentBinaries(String uuid, Documents metaDoc,
			int version, String path) {
		DocumentBinariesDAO binaryDAO = DAOFactory.DEFAULT.getDocumentBinariesDAO();
		binaryDAO.insertDocumentBinary(uuid, metaDoc, version, path);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#getCurrentVersion(java.lang.String)
	 */
	public int getCurrentVersion(String docUuid) {
		DocumentBinariesDAO binaryDAO = DAOFactory.DEFAULT.getDocumentBinariesDAO();
		return binaryDAO.getCurrentVersion(docUuid);
	}

	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#makePersistent(us.gaaoc.framework.model.DocumentBinaries)
	 */
	public void makePersistent(DocumentBinaries documentBinaries) {
		DocumentBinariesDAO binaryDAO = DAOFactory.DEFAULT.getDocumentBinariesDAO();
		binaryDAO.makePersistent(documentBinaries);
	}

	@Override
	public void updateExternalCaseNumber(String uuid,
			String newExternalCaseNumber) {
		CaseRecordExternalCaseRecordNumberDAO externalDAO = DAOFactory.DEFAULT.getCaseRecordExternalCaseRecordNumberDAO();
		externalDAO.updateExternalCaseNumber(uuid, newExternalCaseNumber);
	}

	@Override
	public List<ParticipantRelationship> getAllParticipantRelationshipCodes() {
		PersonParticipantsDAO ppDAO = DAOFactory.DEFAULT.getPersonParticipantsDAO();
		return ppDAO.getAllParticipantRelationshipCodes();
	}

	public PersonOrganizations makePersistent(PersonOrganizations po) {
		PersonOrganizationsDAO poDAO = DAOFactory.DEFAULT.getPersonOrganizationsDAO();
		return poDAO.makePersistent(po);
	}

	@Override
		public Person findAttorneyByBarIDAndOrgAsPerson(String barID,String courtUuid) {
			AttorneyDAO atDAO = DAOFactory.DEFAULT.getAttorneyDAO();
			
			// TODO Auto-generated method stub
			return atDAO.findAttorneyByBarIDAndOrgAsPerson(barID,courtUuid);
		}
		
		public Attorney findAttorneyByBarIDAndOrg(String barID, Organizations org)
		{
			AttorneyDAO atDAO = DAOFactory.DEFAULT.getAttorneyDAO();
			return atDAO.findAttorneyByBarIDAndOrg(barID,org);
		}
	
		/*
	public LegalPreparer findLegalPreparerByPersonAndOrg(Person person, String org)
	{
		LegalPreparerDAO lpDAO = DAOFactory.DEFAULT.getLegalPreparerDAO();
		return lpDAO.findLegalPreparerByPersonAndOrg(person, org);
		
	}
	*/
	
	public  PersonOrganizations findPersonOrganizationByCourtAndPerson(
			Person personFiler, String courtUuid)
	{
		PersonOrganizationsDAO poDAO = DAOFactory.DEFAULT.getPersonOrganizationsDAO();
		return poDAO.findPersonOrganizationByCourtAndPerson(personFiler,courtUuid);
	}

	@Override
	public Attorney getNullAttorney(Organizations organization) {
		AttorneyDAO attorneyDAO = DAOFactory.DEFAULT.getAttorneyDAO();
		return attorneyDAO.getNullAttorney(organization);
	}

	@Override
	public String getBarID(Person person, Court court) {
		AttorneyDAO attorneyDAO = DAOFactory.DEFAULT.getAttorneyDAO();
		return attorneyDAO.getBarID(person,court);
	}

	public String generateDocketId(String prefix, String courtUuid) {
		CaseRecordDAO cdao = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return cdao.generateDocketId(prefix);
	}
	
	public void updateCaseRecord(CaseRecord caseRecord, String courtUuid) {
		CaseRecordDAO cdao = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		cdao.updateCaseRecord(caseRecord);
	}
	
	public List<PersonParticipants> getPersonParticipantByPerson(
			Person personParticipant) {
		PersonParticipantsDAO ppDAO = DAOFactory.DEFAULT
				.getPersonParticipantsDAO();
		return ppDAO.getPersonParticipantByPerson(personParticipant);
	}

	public List<DocumentInstance> findAllDocumentsByCourt(String courtUuid) {
		DocumentInstanceDAO dao = DAOFactory.DEFAULT.getDocumentInstanceDAO();
		return dao.findAllDocumentsByCourt(courtUuid);
	}
	
	public void insertDocumentPackage(DocumentPackage doc,
			ArrayList<DocPageRange> pageRanges) {
		DocumentPackageDAO dp = DAOFactory.DEFAULT.getDocumentPackageDAO();
		dp.makePersistent(doc);
		
		DocPageRangeDAO dpr = DAOFactory.DEFAULT.getDocPageRangeDAO();
		for (DocPageRange docPageRange : pageRanges) {
			dpr.makePersistent(docPageRange);
		}
	}

	public boolean findCivilActionNumber(String cvNumber, String courtUuid) {
		CaseRecordDAO c = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);
		return c.findCivilActionNumber(cvNumber);
	}
	
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#countDocumentAssociations(java.lang.String)
	 */
	public int countDocumentAssociations(String documentUuid) {
		CourtSealDAO courtSealDAO = DAOFactory.DEFAULT.getCourtSealDAO();
		int cs = courtSealDAO.countDocumentAssociations(documentUuid);
		return cs;
	}
	public List<CourtSeal> getDuplicateCourtSealList(String documentUuid) {
		CourtSealDAO courtSealDAO = DAOFactory.DEFAULT.getCourtSealDAO();
		List<CourtSeal> cs = courtSealDAO.getDuplicateCourtSealList
			(documentUuid);
		return cs;
	}
	/*
	 * (non-Javadoc)
	 * @see us.gaaoc.framework.dao.ModelFacade#findCourtSealByID(java.lang.int)
	 */
	public CourtSeal findCourtSealByID(int row) {
		CourtSealDAO courtSealDAO = DAOFactory.DEFAULT.getCourtSealDAO();
		CourtSeal cs = courtSealDAO.findCourtSealByID(row);
		return cs;
	}

	@Override
	public LegalPreparer findLegalPreparerByPersonAndOrg(Person personFiler,
			String uuid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<LegalPreparer> getLegalPreparers(Person personFiler,
			Organizations organization) {
		return (DAOFactory.DEFAULT.getLegalPreparerDAO()).getLegalPreparers(personFiler, organization);
	}


	@Override
	public PersonOrganizations findPersonOrganization(String id) {
		return (DAOFactory.DEFAULT.getPersonOrganizationsDAO()).findById(id);
	}

	@Override
	public List<CaseRecordAction> getCaseRecordActionsByCaseType(int i) {
		return (DAOFactory.DEFAULT.getCaseRecordActionDAO()).getActionsByCaseType(i);
	}

	@Override
	public CaseRecordAction getCaseRecordActionsById(
			int externalCaseCategoryCode) {
		return (DAOFactory.DEFAULT.getCaseRecordActionDAO()).findById(new Integer(externalCaseCategoryCode));
	}

	@Override
	public Session getSession() {		
		return DAOFactory.HIBERNATE.getCurrentSession();
	}

	@Override
	public void updateCourtDateExtendedData(String caseRecordUuid, int dataID,
			String value) {
		(DAOFactory.DEFAULT.getCourtEventsDAO()).updateCourtDateExtendedData(caseRecordUuid,dataID,value);		
	}
	
	public List<DocumentPackage> findDocumentPackageByCaseRecordAction(Court court,CaseRecordAction cra) {
		DocumentPackageDAO docPackageDAO = DAOFactory.DEFAULT.getDocumentPackageDAO();
		return docPackageDAO.findDocumentPackageByCourtandCaseRecordAction(court,cra);
	}
	
	
	/**
	 * These 4 methods are added to facilitate the Report Summary Page
	 */
	
	public List<Filing> findAllCaseRecordByStatusandCreatedDate(int statusCode,String courtUuid,Date startInstantiationDateTime,Date endInstantiationDateTime) {
		CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);		
		return caseRecordDAO.findAllCaseRecordByStatusandCreatedDate(statusCode,courtUuid, startInstantiationDateTime,endInstantiationDateTime);
		
	} 


public List<Filing> findAllCaseRecordByStatusCodeandLatestEventDateTime(int statusCode,String courtUuid,Date startEventDateTime,Date endEventDateTime) {
	CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);		
	return caseRecordDAO.findAllCaseRecordByStatusCodeandLatestEventDateTime(statusCode,courtUuid, startEventDateTime,endEventDateTime);
	
} 


public  List<Filing> findAllCaseRecordByEventCodeandLatestEventDateTime(int eventCode,String courtUuid,Date startEventDateTime,Date endEventDateTime)
{
	CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);		
	return caseRecordDAO.findAllCaseRecordByEventCodeandLatestEventDateTime(eventCode,courtUuid, startEventDateTime,endEventDateTime);
	
}

public  List<Filing> findAllCaseRecordByEventCodeandEventDateTime(int eventCode,String courtUuid,Date startEventDateTime,Date endEventDateTime)
{

	CaseRecordDAO caseRecordDAO = DAOFactory.DEFAULT.getCaseRecordDAO(courtUuid);		
	return caseRecordDAO.findAllCaseRecordByEventCodeandEventDateTime(eventCode,courtUuid, startEventDateTime,endEventDateTime);
	

}

public SignatureImage findImageByUuid (String uuid){
	
	SignatureImageDAO signatureImageDAO = DAOFactory.DEFAULT.getSignatureImageDAO();		
	return signatureImageDAO.findImageByUuid(uuid);
	

	
}

@Override
public List<CaseRecordStatus> getCaseRecordStatusList() {
	CaseRecordStatusDAO crs = DAOFactory.DEFAULT.getCaseRecordStatusDAO();		
	return crs.findAll();
}

	
	
} 